﻿@{
    ViewBag.Title = "title";
}
@Html.Partial("Head")
<h2>CoffeeDemo</h2>


<p></p>
<b>-------------------------</b>


<script>
    //
    var result = [];
    for (var i = 0; i < 10; i++) {
        result.push(function () { return i; });
    }
    console.log(result[5]()); // 10, not 5


    var result = [];
    for (var i = 0; i < 10; i++) {
        (function (i) {  // copied i
            result.push(function () { return i; });
        }(i)); // original i
    }
</script>